<template>
  <div class="report-display">
    <div class="report-header">
      <h2>{{ currentReport.title }}</h2>
      <div class="report-actions">
        <el-button type="primary" @click="handleExport">
          <el-icon><Download /></el-icon>
          导出
        </el-button>
        <el-button @click="handleRefresh">
          <el-icon><Refresh /></el-icon>
          刷新
        </el-button>
      </div>
    </div>
    
    <div class="report-content">
      <!-- 这里可以根据不同的报表类型显示不同的内容 -->
      <el-table
        v-if="currentReport.type === 'table'"
        :data="tableData"
        style="width: 100%"
        border
        height="100%"
      >
        <el-table-column
          v-for="col in currentReport.columns"
          :key="col.prop"
          :prop="col.prop"
          :label="col.label"
        />
      </el-table>
      
      <!-- 图表展示区域 -->
      <div v-else-if="currentReport.type === 'chart'" class="chart-container">
        <div class="chart-placeholder">
          图表展示区域
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, watch } from 'vue'
import { Download, Refresh } from '@element-plus/icons-vue'

const props = defineProps({
  selectedMenu: {
    type: String,
    default: '1'
  }
})

// 模拟当前报表数据
const currentReport = ref({
  title: '工资报表',
  type: 'table',
  columns: [
    { prop: 'name', label: '姓名' },
    { prop: 'department', label: '部门' },
    { prop: 'position', label: '职位' },
    { prop: 'salary', label: '工资' }
  ]
})

// 模拟表格数据
const tableData = ref([
  {
    name: '张三',
    department: '技术部',
    position: '工程师',
    salary: '15000'
  },
  {
    name: '李四',
    department: '人事部',
    position: '经理',
    salary: '20000'
  }
])

// 监听菜单选择变化
watch(() => props.selectedMenu, (newVal) => {
  // 这里可以根据选中的菜单更新报表内容
  console.log('Selected menu changed:', newVal)
})

const handleExport = () => {
  // 实现导出功能
  console.log('导出报表')
}

const handleRefresh = () => {
  // 实现刷新功能
  console.log('刷新报表')
}
</script>

<style scoped>
.report-display {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e6e6e6;
  background-color: #fff;
  flex-shrink: 0;
}

.report-header h2 {
  margin: 0;
  font-size: 20px;
  color: #303133;
}

.report-actions {
  display: flex;
  gap: 10px;
}

.report-content {
  flex: 1;
  padding: 20px;
  overflow: auto;
  background-color: #fff;
  height: calc(100% - 60px);
}

.chart-container {
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.chart-placeholder {
  width: 100%;
  height: 100%;
  background-color: #f5f7fa;
  border: 1px dashed #dcdfe6;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #909399;
  font-size: 16px;
}

:deep(.el-table) {
  height: 100% !important;
}

:deep(.el-table__body-wrapper) {
  overflow-y: auto;
}
</style> 